﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace NCLCustomerManagement.DataTransferObjects.Customer
{
    public enum Region
    {
        North = 0,
        Middle = 1,
        South = 2
    }

    public class CustomerDTO : BaseDTO
    {
        [Key]
        public int Id { get; set; }
        public string CustomerName { get; set; }
        public Region CustomerRegion { get; set; }
        public string Phone { get; set; }
        public string CreditCardNumber { get; set; }
        public string Bank { get; set; }
        public string Address { get; set; }
        public string Notes { get; set; }
        public string LastModifiedUser { get; set; }
        public DateTime LastModifiedDate { get; set; }
        public List<ProductCategoryDTO> Products { get; set; }

        public CustomerDTO()
        {

        }

        public override bool Equals(object obj)
        {
            CustomerDTO other = obj as CustomerDTO;
            if (this.Id != other.Id) return false;
            if (this.Address != other.Address) return false;
            if (this.CustomerName != other.CustomerName) return false;
            if (this.CustomerRegion != other.CustomerRegion) return false;
            if (this.Notes != other.Notes) return false;
            if (this.Phone != other.Phone) return false;
            if (this.Address != other.Address) return false;

            if (this.Products.Count != other.Products.Count) return false;
            if (this.Products.Select(e => e.Id)
                .Except(other.Products.Select(e => e.Id))
                .Count() != 0) return false;
            if (other.Products.Select(e => e.Id)
               .Except(this.Products.Select(e => e.Id))
               .Count() != 0) return false;
            return true;
        }
    }
}
